#ifndef CHARACTER_HH
#define CHARACTER_HH

#include "Skill.hh"
#include "Equipment.hh"
#include "Talent.hh"
#include "AttributeBonuses.hh"
#include <vector>
#include <memory>
#include <string>
#include <map>

struct Bonus {
    std::string source; // Source of the bonus (equipment, talent, or potion name)
    int value;         // Bonus value
    bool isTemporary;  // Added: Indicates if the effect is temporary
};

class Character {
public:
    Character(); // 1
    Character(const std::string& name, const std::string& desc);
    Character(Character&& other) noexcept;
    Character& operator=(Character&& other) noexcept;
    // need to code the function for those two 
    Character(const Character&) = delete; //2 
    Character& operator=(const Character&) = delete; //3
    // --
    virtual ~Character() = default; // 4
    virtual void displayInfo() const;
    void addSkill(const Skill& skill);
    bool addEquipment(const Equipment& equip);
    void addTalent(const Talent& talent, int layer);
    void onEnemyDefeated();
    bool isControlImmune() const { return controlImmune; }
    bool handleFatalDamage();
    void heal(int amount);
    
    const std::map<std::string, std::vector<Bonus>>& getAttributeBonuses() const;

    std::string name;
    std::string description;
    AttributeBonuses attributes;
    int maxHealth;
    std::vector<Skill> skills;
    std::vector<Talent> talents;
    bool isStunned = false;
    bool isHealingDisabled = false; // Whether healing effects are disabled

    std::unique_ptr<Equipment> weapon;
    std::unique_ptr<Equipment> helmet;
    std::unique_ptr<Equipment> armor;
    std::unique_ptr<Equipment> leggings;
    std::unique_ptr<Equipment> boots;
    std::unique_ptr<Equipment> accessory;

private:
    void applyEquipmentBonuses(const Equipment& equip);
    std::map<std::string, std::vector<Bonus>> attributeBonuses;
    bool fatalBlockAvailable = false;
    float passiveAttackMultiplier = 1.0f;
    bool controlImmune = false;
    int defeatedEnemies = 0; // Added: Tracks the number of enemies defeated by Berserker
};

#endif // CHARACTER_HH